package com.dataseek.iot.mysql.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dataseek.iot.mysql.entity.Line;
import com.dataseek.iot.mysql.mapper.LineMapper;
import com.dataseek.iot.mysql.service.ILineService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cc
 * @since 2021-09-06
 */
@Service
public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements ILineService {


    /**
     * 查询线路信息
     * @param roleId
     * @return
     */
    public List<Line> getLinesByRoleId(String roleId){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("role_id", roleId);
        return this.list(wrapper);
    }


    /**
     * 根据code获取信息
     * @param code
     * @return
     */
    public Line getOneByCode(String code){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("line_code", code);
        return this.getOne(wrapper);
    }

    /**
     * 根据线路编码查询线路
     * @param code
     * @return
     */
    public List<Line> getLinesByCode(String code){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.like("line_code", code);
        return this.list(wrapper);
    }

    /**
     * 根据区县编码查询线路
     * @param code
     * @return
     */
    public List<Line> getLinesByAreaCode(String code){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("area_code", code);
        return this.list(wrapper);
    }

}
